package com.litchi.tutor.controller;

import com.litchi.tutor.common.base.ResponseVO;
import com.litchi.tutor.common.entity.Region;
import com.litchi.tutor.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author XuRuiPeng
 * @date 2021/10/28 9:10
 */
@RestController
@RequestMapping("/region")
@Api("行政区划管理")
public class RegionController {

    @Autowired
    RegionService regionService;

    @ApiOperation("获取行政区划")
    @RequestMapping(value = "/region", method = RequestMethod.GET)
    public ResponseVO getRegion(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "mode", required = false) String model) {
        Map<String, Object> region = regionService.getRegion(code, model);
        return ResponseVO.ok(region);
    }

    @ApiOperation("test")
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public ResponseVO getRegionTets() {
        Map<String, List<Region>> test = regionService.test2();
        return ResponseVO.ok(test);
    }
}